/**
 * @description: axios封装
 * @param {*} source 店铺类型  10 快手   7 抖店
 * @param {*} url 接口
 * @param {*} data 入参
 * @param {*} method 接口类型
 * @return {*}
 */
function request(source = 10, url = "", data = null, method = "get") {
    if(typeof source === 'number'){
        axios.defaults.baseURL = tabTypes.find(
          (item) => item.source === source
        ).baseURL;
    }else if(typeof source === 'string' && source){
        axios.defaults.baseURL = source
    }
  axios.defaults.timeout = 10000;
  axios.defaults.headers.post["Content-Type"] =
    "application/x-www-form-urlencoded";
  const config = {};
  config["method"] = method;
  config["url"] = url;
  switch (method) {
    case "get":
      config["params"] = data;
      break;
    case "post":
      config["data"] = data;
  }
  return new Promise((resolve, reject) => {
    axios(config)
      .then((res) => {
        if (res.status === 200) {
          resolve(res.data);
        } else {
          reject(false);
        }
      })
      .catch((err) => {
        reject(err);
      });
  });
}
